package Presetacion;


import java.util.ArrayList;
import javax.swing.ImageIcon;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Casillero.java
 *
 * Created on 08-oct-2011, 18:27:20
 */
/**
 *
 * @author Rodrigo
 */
public class Casillero extends javax.swing.JPanel {
    
    private Tablero tab;
    private int pos;
    private Ficha ficha;
    private ArrayList<Casillero> vecinos = new ArrayList<Casillero>(4);

    /** Creates new form Casillero */
    public Casillero() {
        this(0,null,null);
    }

    public Casillero(int posicion,Tablero tab, Ficha ficha) {
        initComponents();
        this.setOpaque(false);
        setFicha(ficha);
        pos = posicion;
        this.tab=tab;
    }

    public int getPosicion() {
        return pos;
    }

    public void addVecino(Casillero cas) {
        vecinos.add(cas);
    }
    
    public Tablero getTablero()
    {
        return tab;
    }

    public ArrayList<Casillero> getVecionos() {
        return vecinos;
    }

    public void setFicha(Ficha fich) {
        if (ficha == fich) {
            return;
        }
        ficha = fich;
        this.removeAll();
        
        if(ficha==null)
            return;
        
        ficha.setCasillero(this);        
        this.add(ficha, java.awt.BorderLayout.CENTER);
    }

    public Ficha getFicha() {
        return ficha;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        setLayout(new java.awt.BorderLayout());
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
